import axios from  './http'
//获取轮播图
export function loop(number) {

    return axios.get(`/api/weChat/applet/course/banner/list?number=${number}`)
}

//请求课程列表
export  function courseList(number){
    return axios.post("http://wkt.myhope365.com/weChat/applet/subject/list",
        {"enable":number})
}

//请求课程数据
function csourseList(type,pageSize,pageNum=1) {
    // let formData = new URLSearchParams()
    let formData = new FormData()
    formData.append("type",type)
    formData.append("pageSize",pageSize)
    formData.append("pageNum",pageNum)

    return axios.post(`/api/weChat/applet/course/list/type`,formData)

}
export {csourseList}

//课程详情请求
export function detail(number){
    return axios.get(`/api/pc/course/detail/${number}`)
}

//课程评论
export function commentDetail(number){
    return axios.get(`/api/pc/comment/commentList/course/${number}?pageSize=10&pageNum=1`)
}

//请求底部链接
export function footerLike(){
    let form = new FormData();
    form.append("dictType", "blogroll");
    form.append("pageNum", 1);
    form.append("pageSize", 10);
    form.append("orderByColumn", "dictSort");
    form.append("isAsc", "asc");
    return  axios.post("http://wkt.myhope365.com/system/dict/data/list/open", form)
}

//请求登录
export function login(username,password) {
    let form = new  FormData()
    form.append("username",username)
    form.append("password",password)
    form.append("rememberMe",true)

    return axios.post(`/api/pcUser/login`,form)

}
//手机号登录发送验证码
export function  phoneverfication(mobile){
    return axios.get(`/api/pcUser/login/send/code/${mobile}`)
}

//手机号登录
export function phoneLogin(phone,code){
    let form = new  FormData()
    form.append("mobile",phone)
    form.append("code",code)
    form.append("rememberMe",true)

    return axios.post(`/api/pcUser/login/mobile`,form)

}


//查看登录用户个人信息
export  function getUserInfo() {
    return axios.get("/api/pcUser/login-user/info")

}
//退出登录
export  function logout() {
    return axios.get("/api/pcUser/logout")

}
//更改头像
export  function changeUserAvatar(file) {
    let formData = new  FormData()
    formData.append("file",file)
    return axios.post("/api/pcUser/updata/userAvatar",formData)

}
//获取注册验证码
export function  verfication(mobile){
    return axios.get(`/api/pcUser/register/send/code/${mobile}`)
}

//注册
export  function signIn(name,code,phone,password,username){
    let formData = new  FormData()
    formData.append("loginName",name)
    formData.append("code",code)
    formData.append("mobile",phone)
    formData.append("password",password)
    formData.append("nickname",username)
    return axios.post("/api/pcUser/register",formData)
}

//忘记密码验证码
export function forget(name,phone){
    let formData = new  FormData()
    formData.append("loginName",name)
    formData.append("mobile",phone)
    return axios.post("/api/pcUser/forgetpassword/send/code",formData)
}

//忘记密码
export function forgetPassword(name,password,phone,code){
    return axios.post("/api/pcUser/password/forget",{
        "loginName":name,
        'password':password,
        "mobile":phone,
        'code':code,
    })
}

